<!DOCTYPE html>
<html>

	<head>
		<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="./css/iuapmobile.um.css">
		<link rel="stylesheet" href="./css/font-icons.css">
		<script src="./js/summer.js"></script>
		<script src="./js/jquery.min.js"></script>
		<script src="./js/Frameworks/iuapmobile.frameworks.ui.js"></script>
		<script>
			$(function() {
				$(".um-input-clear").click(function() {
					$(this).prev("input").val("");
				})
			})
		</script>
	</head>

	<body>
		<div class="um-win" id="index">
			<div class="um-header">
				<h3>导航栏</h3>
			</div>

			<div class="um-content">
				<button class="btn" onclick="openPhotoAlbum()">选择图片</button>
				<button class="btn" onclick="upload()">上传图片</button>
				<br/><br/><br/>
				
				<img id="img" src="" style="width: 100px;height: 100px" />
				<div class="pr">
					<input type="text" id="texts" class="form-control" placeholder="该输入框文本可以清除">
					<span class="um-input-clear ti-close"></span>
				</div>
				<button class="btn" onclick="tu()">设置图片路径</button>
				

			</div>

			<div class="um-footer">

			</div>
		</div>
	</body>

</html>

<script>
	summerready = function(){
	}
	var img; //选择的图片
	function upload() {
		summer.upload({
			fileURL: img,
			type: "image/jpeg",
			params: {},
			SERVER: "http://10.10.30.155:8090/Handler.ashx"
		}, function(ret) {
			alert("成功" + JSON.stringify(ret));
		}, function(err) {
			alert("失败" + JSON.stringify(err));
		});
	}
	
	function tu(){
		document.getElementById("img").src = $("#texts").val();
	}
	
	
	function openPhotoAlbum() {
	try {
		summer.openCamera({
			cameraType: "custom", //解决IOS内存崩溃
			callback: function(args) {
				if(summer.getSysInfo().systemType == "android") {
					try {
						setTimeout(function() {
							summer.callService("UMFile.compressImg", { //compressImgInThread
								"src": args.imgPath,
								"path": args.imgPath,
								"compressWidth": "1200",
								"compressHeight": "1200",
								"quality": "0.8",
								"callback": function(arg) {
									img = arg.savepath;
									alert(img);
								}
							}, false);
						}, 600);
					} catch(e) {
						alerts("压缩图像时出错了" + e);
					}
				} else {
					try {
						setTimeout(function() {
							summer.callService("UMFile.compressImg", { //compressImg
								"src": args.imgPath,
								"path": args.imgPath,
								"compressWidth": "1200",
								"compressHeight": "1200",
								"quality": "0.8",
								"callback": function(arg) {
									img = arg.path;
									alert(img);
								}
							}, false);
						}, 600);
					} catch(e) {
						alerts("压缩图像时出错了" + e);
					}
				}
			}
		});
	} catch(e) {
		alerts(e);
	}
}
</script>
<script src="js/Myjs/common.js"></script>
<script src="js/Myjs/zhancun.js"></script>